﻿@namespace ThingsBlazor.Web.Rcl.Core
@typeparam TItem where TItem : IDefaultItem<TItem>

<MList Expand Dense
       Nav 
       Class="@ClassString" Style="@StyleString"
       >
    @foreach (var item in Items)
    {
        @*副标题*@
        if (item.Heading is not null)
        {
            <MSubheader Class="text--primary font-weight-black ">@item.Heading</MSubheader>
        }
        @*分割线*@
        else if (item.Divider)
        {
            <MDivider Class="mt-3 mb-2 ml-2 mr-n2" />
        }
        @*子菜单*@
        else if (item.HasChildren())
        {
            <DefaultListGroup Item="item" />
        }
        else if (ItemContent != null)
        {
            @ItemContent.Invoke(item)
        }
        @*默认实现菜单*@
        else
        {
            <DefaultListItem Item="item" />
        }
    }

</MList>

@code {

    [Parameter]
    public List<TItem> Items { get; set; } = new();

    [Parameter]
    public RenderFragment<TItem> ItemContent { get; set; }

    [Parameter]
    public string ClassString { get; set; }
    [Parameter]
    public string StyleString { get; set; }
}
